﻿// JScript 文件

function $(obj)
{
    return document.getElementById(obj);
}
function xmlhttp()
{
	var A=null;
	try
	{
		A=new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
		try
		{
			A=new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(oc)
		{
			if (typeof XMLHttpRequest != "undefined" );
			{
				A=new XMLHttpRequest();
			}
		}
	}			
	return A;
}


function GetUserAjax(Uid )
{
    //alert(1);
    //debugger;
	var oXmlHttp = xmlhttp();	
	try
	{
		oXmlHttp.open("POST","Handler.ashx?b="+Uid+"&action=lotery&a="+Math.random(),true);

		oXmlHttp.onreadystatechange = function()
		{	
 	        if (oXmlHttp.readyState == 4 && oXmlHttp.status == 200)
	        {
 		        result = oXmlHttp.responseText;
		        //alert(oXmlHttp.responseText);
		        
 		        get_user(oXmlHttp.responseText);
  	        }
		}
		oXmlHttp.send(null);	
 	} 
	catch (e) 
	{
		// return "";
	}
} 
function get_user(obj)
{
    if ( obj == 1 ) {alert("领取成功");GetUserAjax_lingqu("zjsome");}
    else if ( obj == 0 ) {alert("不能重复领取");}
    else if ( obj == -1 ) {alert("条件不够哦");}
    else if ( obj == -2 ) {alert("领取失败");}
    else if ( obj == -10 ) {alert("活动还没开始哦");}
    
}


function GetUserAjax_paihang(Uid )
{
    //alert(1);
    //debugger;
	var oXmlHttp = xmlhttp();	
	try
	{
		oXmlHttp.open("POST","Handler.ashx?b=2&action="+Uid+"&a="+Math.random(),true);

		oXmlHttp.onreadystatechange = function()
		{	
 	        if (oXmlHttp.readyState == 4 && oXmlHttp.status == 200)
	        {
 		        result = oXmlHttp.responseText;
		        //alert(oXmlHttp.responseText);
 		        //paihang_user(oXmlHttp.responseText);
 		        if (result.length > 0)
 		        {
 		            $("user_ph_some").innerHTML= result;
 		        }
  	        }
		}
		oXmlHttp.send(null);	
 	} 
	catch (e) 
	{
		// return "";
	}
} 


function GetUserAjax_lingqu(Uid )
{
    //alert(1);
    //debugger;
	var oXmlHttp = xmlhttp();	
	try
	{
		oXmlHttp.open("POST","Handler.ashx?b=3&action="+Uid+"&a="+Math.random(),true);

		oXmlHttp.onreadystatechange = function()
		{	
 	        if (oXmlHttp.readyState == 4 && oXmlHttp.status == 200)
	        {
 		        result = oXmlHttp.responseText;
		        //alert(oXmlHttp.responseText);
 		        bool_user(oXmlHttp.responseText);
  	        }
		}
		oXmlHttp.send(null);	
 	} 
	catch (e) 
	{
		// return "";
	}
} 

function bool_user(obj)
{
    var nn = obj.split(',');
    for(var i =0 ;i< nn.length;i++)
    {
        var mm = nn[i];
        
        if( mm == 1) 
        {
            $("lq1").className = "getted";
            $("lq1").value = "已领取";
            $("lq1").disabled = true;
        }
        if( mm == 2) 
        {
            $("lq2").className = "getted";
            $("lq2").value = "已领取";
            $("lq2").disabled = true;
        }
        if( mm == 3) 
        {
            $("lq3").className = "getted";
            $("lq3").value = "已领取";
            $("lq3").disabled = true;
        }
        if( mm == 4) 
        {
            $("lq4").className = "getted";
            $("lq4").value = "已领取";
            $("lq4").disabled = true;
        }
        if( mm == 5) 
        {
            $("lq5").className = "getted";
            $("lq5").value = "已领取";
            $("lq5").disabled = true;
        }
        
    }
}